//
//  RadioTableViewCell.m
//  CoolFM
//
//  Created by 曹曹 on 16/8/31.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "RadioTableViewCell.h"
#import "Program_List_All.h"
#import "UIImageView+WebCache.h"
#import "RadioDetailViewController.h"
#import "GX_Button.h"
#import "CFMacro.h"

@interface RadioTableViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *radioImage;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UILabel *popularyty;
@property (weak, nonatomic) IBOutlet UILabel *hzLabel;
@property (weak, nonatomic) IBOutlet UILabel *personLabel;
@property (weak, nonatomic) IBOutlet UIImageView *djImage;
@property (nonatomic, strong) UIViewController *vc;
@property (nonatomic, assign) BOOL isOpen;
@property (weak, nonatomic) IBOutlet GX_Button *detailBtn;

@end

@implementation RadioTableViewCell

- (void)setProgramlist:(Program_List_All *)programlist {
    _programlist = programlist;
    if (IS_IPHONE_5) {
        _popularyty.font = [UIFont systemFontOfSize:9];
        _personLabel.font = [UIFont systemFontOfSize:9];
    }
    _popularyty.text = [NSString stringWithFormat:@"人气: %ld", programlist.listener_count];
    if (programlist.listener_count > 999) {
        NSInteger single = programlist.listener_count / 10000;
        NSInteger deciml = programlist.listener_count % 10000 / 1000;
        NSString *num = [NSString stringWithFormat:@"%ld.%ld", single, deciml];
        _popularyty.text = [NSString stringWithFormat:@"人气: %@万", num];
    }
    _titleLabel.text = programlist.channel_name;
    _detailLabel.text = programlist.program_name;
    _hzLabel.text = [programlist.channel_hz componentsSeparatedByString:@" "].firstObject;
    _personLabel.text = programlist.program_dj;
    if ([_personLabel.text isEqualToString:@""]) {
        _djImage.alpha = 0;
    } else {
        _djImage.alpha = 1;
    }
    [_radioImage sd_setImageWithURL:[NSURL URLWithString:_programlist.channel_image_url]
                   placeholderImage:[UIImage imageNamed:@"img_dj_head"]];
}
- (IBAction)moreButtonClicked:(id)sender {
//    RadioDetailViewController *radioDetailVC = [[RadioDetailViewController alloc] init];
//    radioDetailVC.playKey = _programlist.channel_key;
//    [self.vc.navigationController pushViewController:radioDetailVC animated:YES];
    self.button(self.detailBtn);
    
}

- (UIViewController *)vc {
    id responder = self.nextResponder;
    while (![responder isKindOfClass:[UIViewController class]] && responder != nil) {
        responder = [responder nextResponder];
    }
    return (UIViewController *)responder;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
